﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;


namespace chatblog.bbsmanage
{
    public partial class adv : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser.dealcookie();
                dealrequest();
                bind1();
            }
        }
        private void dealrequest()
        {
            if (AliApi.appUserId == "")
            {
                Response.Redirect(ResolveUrl("~/login/login.aspx?redirecturl=") + ResolveUrl("~/bbsmanage/adv.aspx"));
            }
        }
        /// <summary>
        /// 绑定
        /// </summary>
        private void bind1()
        {
            cbadv u = cbadv.findorcreate(AliApi.appUserId,"");
            this.Fck_Content .Value = Server.HtmlDecode(u.jcdesc1.ToString());
            this.FCKeditor1.Value = Server.HtmlDecode(u.jcdesc2.ToString());
            this.FCKeditor2.Value = Server.HtmlDecode(u.jcdesc3.ToString());
            cbarea area = cbarea.Find(" cbuserid = '" + AliApi.appUserId + "' ");
            DataTable a1;
            string sql = "";
            //总发帖量
            sql = " select count(*) from vcblist where cbstatus = '有效' "
                + " and ( cbcatastatus = '" + area.cbareaid.ToString()
                + "' or cbcatastatus = '全部')";
            a1 = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
            int i = zfunction.str2int(a1.Rows[0].ItemArray[0].ToString());
            if (i >= 1000)
            {
                Button1.Enabled = true
                    ;
            }
            else
            {
                Button1.Enabled = false
                      ;
            
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            cbadv u = cbadv.findorcreate(AliApi.appUserId, "");
            u.jcdesc1.Value = Fck_Content.Value.Trim();
            u.jcdesc2.Value = FCKeditor1.Value.Trim();
            u.jcdesc3.Value = FCKeditor2.Value.Trim();
            u.Modify();
        }
    }
}
